package org.zcl.service.impl;

import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.zcl.mq.MessageQueue;
import org.zcl.service.IMessageProvider;

import javax.annotation.Resource;
import java.util.UUID;


/**
 * .
 *
 * @author zhuchenglin
 * @since 2024/7/19 17:28
 */
@EnableBinding(MessageQueue.Send.class)
public class MessageProviderImpl implements IMessageProvider {

    @Resource
    private MessageChannel output;

    @Override
    public String send() {
        String serial = UUID.randomUUID().toString();
        // 创建并发送消息
        this.output.send(MessageBuilder.withPayload(serial).build());
        System.out.println("***serial: " + serial);
        return serial;
    }
}
